package com.wewins.fota.bean.bo.filter;

import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.List;

@Data
public class PlanFilterCond implements FilterCond {
    private String name;

    private String type;

    private String product;

    private String srcV;

    private String dstV;

    private String owner;

    private List<Long> timeRange;

    public Long getMinTime() {
        if (timeRange == null || timeRange.size() != 2) {
            return 0L;
        }
        return timeRange.get(0);
    }

    public Long getMaxTime() {
        if (timeRange == null || timeRange.size() != 2) {
            return 0L;
        }
        return timeRange.get(1);
    }

    public String getType() {
        if (StringUtils.isEmpty(type)) {
            return "";
        }
        return "\"type\":\"" + type + "\"";
    }

    public String getOwner() {
        if (StringUtils.isEmpty(owner)) {
            return "";
        }
        return "\"owner\":\"" + owner + "\"";
    }
}
